package org.onepiece.admin.integration.manager.impl;

import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.onepiece.admin.entity.dto.context.OrderContext;
import org.onepiece.admin.integration.handler.ClueHandler;
import org.onepiece.admin.integration.handler.DictHandler;
import org.onepiece.admin.integration.handler.LevelHandler;
import org.onepiece.admin.integration.manager.AbstractOrderService;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * Created by IntelliJ IDEA.
 *
 * @author zhujianke@gaodun.com
 * @since 2023/3/16 21:00
 */
@Slf4j
@Service
@Order(3)
public class OrderCancelServiceImpl extends AbstractOrderService {

    private final ClueHandler clueHandler;

    public OrderCancelServiceImpl(DictHandler dictHandler, LevelHandler levelHandler, ClueHandler clueHandler) {
        super(dictHandler, levelHandler);
        this.clueHandler = clueHandler;
    }

    @Override
    public boolean supports(OrderContext context) {
        return true;
    }

    @Transactional(rollbackFor = Exception.class)
    @Override
    public void handlePayOrder(OrderContext context) {
        log.warn("OrderCancelServiceImpl#handlePayOrder");
        clueHandler.handle();
    }
}
